package cn.group.service.impl;

import cn.group.mapper.LoginMapper;
import cn.group.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.entity.Manager;

@Service
public class LoginServiceImpl implements LoginService {

    @Autowired
    LoginMapper loginMapper;

    @Override
    public Manager findUserByName(String userName) {
        Manager userByName = loginMapper.findUserByName(userName);     //获得当前用户信息
        return userByName;
    }

    @Override
    public Manager checkUser(String userName,String password) {
        if (!"".equals(userName)){
            Manager userByName = loginMapper.findUserByName(userName);     //获得当前用户信息
            if (userByName!=null){
                String password1 = userByName.getPassword();
                System.out.println(userByName);
                if (password.equals(password1)){
                    return userByName;
                }
            }
        }
        return null;
    }

    @Override
    public void saveUser(Manager user) {
        loginMapper.saveUser(user);
    }
}
